package com.jic.product.after.api;

import com.alibaba.fastjson.JSONObject;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.product.after.request.GoodsPageQueryRequest;
import com.jic.product.after.request.MeStoreListRequest;
import com.jic.product.after.request.ProductSaleNumRequest;
import com.jic.product.after.request.SaveProductRequest;
import com.jic.product.after.response.*;
import com.jic.product.manage.response.ProductResponse;
import com.jic.product.rest.response.ProductPropertyResponse;
import com.jic.product.rest.response.ProductResponseFront;
import com.jic.product.store.request.MStoreFrozenRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @date: 2020-01-09
 * @remark: 商品后台管理系统的服务接口
 * <p>
 * feignClient  使用方法:
 * <p>
 * 1.服务提供者编写 FeignClient 属性 name对应注册中心服务Id path为统一前缀  url可以直接指定调用地址（调试用）
 * 2.客户端需要在启动类上加上@EnableFeignClients注解
 * 3.如果通过feignClient调用超时，请设置
 * ribbon:
 * ReadTimeout: 3000
 * ConnectTimeout: 3000
 * 4.客户端依赖该jic-feign-common,在调用处@Resource注解注入 即可调用
 */
@Api(value = "商品中心-提供内部调用-feign", tags = "商品中心-提供内部调用-feign")
@FeignClient(name = "jic-product", path = "/productList")
public interface ProductListApi {
    @PostMapping("/queryProductList")
    RestResult<List<ProductAfterResponse>> queryProductList(@RequestBody List<Long> productIds);

    @PostMapping("/queryProductStock")
    Boolean queryProductStock(@RequestParam("goodsId") String goodsId, @RequestParam("goodsNum") Integer goodsNum);

    @PostMapping("/getSkuByProdId")
    RestResult<ShoppingCartResponse> getSkuByProdId(@RequestBody Long productId);

    @PostMapping("/queryProductInfoById")
    RestResult<ProductAfterInfoByIdResponse> queryProductInfoById(@RequestBody Long productId);

    @PostMapping("/queryProductInfoByThirdProductCode")
    ProductAfterInfoByIdResponse queryProductInfoByThirdProductCode(@RequestBody String thirdProductCode);

    @ApiOperation(value = "保存平台给商家的商品", notes = "保存平台给商家的商品")
    @PostMapping("/saveMerchantProduct")
    RestResult<Boolean> saveMerchantProduct(@RequestBody SaveProductRequest productInfoRequest);

    @ApiOperation(value = "保存商家给店铺的商品", notes = "保存商家给店铺的商品")
    @PostMapping("/saveStoreProduct")
    RestResult<Boolean> saveStoreProduct(@RequestBody SaveProductRequest productInfoRequest);

    @PostMapping("/queryMeStoreList")
    @ApiOperation(value = "查询店铺是否有商品", notes = "查询店铺是否有商品")
    RestResult<List<MeStoreListResponse>> queryMeStoreList(@RequestBody List<MeStoreListRequest> meStoreListRequestList);

    @PostMapping("/queryProductListByIds")
    @ApiOperation(value = "根据商品ids查询商品", notes = "根据商品ids查询商品")
    RestResult<List<ProductResponseFront>> queryProductListByIds(@RequestBody List<Long> productIds);

    @PostMapping("/queryByAllCondition")
    @ApiOperation(value = "营销-根据条件查询spu列表", notes = "根据条件查询spu列表")
    RestResult<PageResult<GoodsPageQueryResponse>> queryByAllCondition(@RequestBody GoodsPageQueryRequest request);

    @PostMapping("/queryMarketById")
    @ApiOperation(value = "营销-根据商品ID查询商品信息", notes = "根据条件查询spu列表")
    RestResult<GoodsPageQueryResponse> queryMarketById(@RequestBody Long productId);

    @PostMapping("/queryProductInfoByParentId")
    @ApiOperation(value = "订单-根据商品父ID查询商品信息", notes = "根据商品父ID查询商品信息")
    RestResult<List<ProductAfterInfoByIdResponse>> queryProductInfoByParentId(@RequestBody Long productId);

    @PostMapping("/frozenStock")
    @ApiOperation(value = "店铺库存扣减", notes = "店铺库存扣减")
    RestResult<Boolean> frozenStock(@RequestBody MStoreFrozenRequest mStoreFrozenRequest);


    @PostMapping("/queryProductByStoreId")
    @ApiOperation(value = "根据店铺id 查询全部商品 SPU和SKU ")
    List<ProductStoreInfo> queryProductByStoreId(@RequestBody GoodsPageQueryRequest goodsPageQueryRequest);


    @PostMapping("/queryProductPageByStoreId")
    @ApiOperation(value = "根据店铺id 查询全部商品 SPU和SKU分页")
    RestResult<PageResult<ProductStoreInfo>> queryProductPageByStoreId(@RequestBody GoodsPageQueryRequest goodsPageQueryRequest);

    @PostMapping("/queryProductBySpuId")
    @ApiOperation(value = "根据spuId 或 spu编码 查询skuList ")
    List<ProductStoreInfo> queryProductBySpuId(@RequestBody GoodsPageQueryRequest goodsPageQueryRequest);

    @PostMapping("/queryProductBySpuList")
    @ApiOperation(value = "根据条件查询spuList和skuList")
    List<ProductStoreInfo> queryProductBySpuList(@RequestBody GoodsPageQueryRequest goodsPageQueryRequest);

    @PostMapping("/queryProductByCode")
    @ApiOperation(value = "根据spu编码 模糊查询 返回spuId")
    List<Long> queryProductByCode(@RequestBody GoodsPageQueryRequest goodsPageQueryRequest);

    @PostMapping("/queryProductListByThirdProductCodes")
    @ApiOperation(value = "根据codelist查询商品")
    List<ProductStoreInfo> queryProductListByThirdProductCodes(@RequestBody GoodsPageQueryRequest goodsPageQueryRequest);

    @PostMapping("/queryMyCommentCount")
    @ApiOperation(value = "查询我的评价数")
    RestResult<Long> queryMyCommentCount(Long memberId);

    @PostMapping("/updateProductSaleNum")
    @ApiOperation(value = "更新商品已售数量")
    Boolean updateProductSaleNum(@RequestBody ProductSaleNumRequest productSaleNumRequest);

    @PostMapping("/queryProductListBySpuId")
    @ApiOperation(value = "根据spuId查询sku商品")
    RestResult<List<ProductStoreInfo>> queryProductListBySpuId(@RequestBody Long spuId);

    @PostMapping("/queryProductListTopTen")
    @ApiOperation(value = "查询热销商品")
    List<HotProductResponse> queryProductListTopTen();

    @PostMapping("/queryProductPropetyBySpuId")
    @ApiOperation(value = "根据spuId查询商品规格信息")
    RestResult<List<ProductPropertyResponse>> queryProductPropetyBySpuId(@RequestParam(value = "productId") Long productId);

    @PostMapping("/queryGoodsTypeById")
    @ApiOperation(value = "查询热销商品")
    List<JSONObject> queryGoodsTypeById(String ids);

    @PostMapping("/queryBySupplierCode")
    @ApiOperation(value = "查询供应商对应的商品信息")
   List<ProductResponse> queryBySupplierCode(@RequestParam("supplierCode") String supplierCode);
}
